﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class quantri_frmAccount : System.Web.UI.Page
{
    DataClassesDataContext db = new DataClassesDataContext();

    protected void Page_Load(object sender, EventArgs e)
    {
        this.loadListAcc();
    }
    protected void loadListAcc()
    {
        String inforAccQuery = "";
        

        var account = from acc in db.Accounts select acc;

        foreach (Account ac in account)
        {

            if (ac.Acc_status == true)
            {
                var permission = (from per in db.Permissions where per.Per_id == ac.Per_id select per).Single();
                inforAccQuery =
                            "<tr><td style='text-align: center;'> " +
                            "<input id='Selectall' type='checkbox' class='checkbox' value='" + ac.Acc_id + "' name ='cbxselectall' />" +
                                "</td>" +
                            "<td style='padding : 5px;'>" +
                               ac.Acc_username + "&nbsp;</td>" +
                            "<td style='padding : 5px;'>" +
                                ac.Acc_fullname + "&nbsp;</td>" +
                            "<td style='width: 60px; padding : 5px; text-align : center ; '> <img src='images/publish_g.png'/>" +
                               "&nbsp;</td>" +
                            "<td style = 'width: 400px;padding: 5px; ' >" +
                            permission.per_keyword + "&nbsp;</td>" +
                            "<td style='padding: 5px;'>" +
                               ac.Acc_email + "&nbsp;</td></tr>";
                lblInforAccount.Text = inforAccQuery;
            }
            else
            {
                var permission = (from per in db.Permissions where per.Per_id == ac.Per_id select per).Single();
                inforAccQuery +=
                                            "<tr><td style='text-align: center;'> <input id='Selectall' type='checkbox' class='checkbox' value='" + ac.Acc_id + "' name='cbxselectall'  />" +
                                                "</td>" +
                                            "<td style='padding : 5px;'>" +
                                               ac.Acc_username + "&nbsp;</td>" +
                                            "<td style='padding : 5px;'>" +
                                                ac.Acc_fullname + "&nbsp;</td>" +
                                            "<td style='width: 60px; padding : 5px;text-align : center ;'> <img src='images/publish_r.png'/>" +
                                               "&nbsp;</td>" +
                                            "<td style = 'width: 400px;padding: 5px; ' >" +
                                            permission.per_keyword + "&nbsp;</td>" +
                                            "<td style='padding: 5px;'>" +
                                               ac.Acc_email + "&nbsp;</td></tr>";
                lblInforAccount.Text = inforAccQuery;
            }
        }
    }
    protected void btnDel_Click(object sender, ImageClickEventArgs e)
    {
        String id = Request.Form["cbxselectall"];
        if (id == null)
        {
            Response.Write("<SCRIPT LANGUAGE='JavaScript'>alert('Vui lòng chọn 1 mục từ danh sách')</SCRIPT>");
            
        }
    }
    protected void btnEdit_Click(object sender, ImageClickEventArgs e)
    {

    }
    protected void btnAdd_Click(object sender, ImageClickEventArgs e)
    {

    }
}
